#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<cmath>
#include<string>
#include<set>
#include<map>

using namespace std;

int solve(int n, int m, int x, int y)
{
	int temp = n + m;
	while (n--)
	{
		int num;
		cin >> num;
	}
	while (m--)
	{
		int k;
		cin >> k;
	}
	return temp;
}

int main()
{
	int t;
	cin >> t;
	while (t--)
	{
		int n, m, x, y;
		cin >> n >> m >> x >> y;
		cout << solve(n, m, x, y) << endl;
	}
	return 0;
}